<template>
	<view>
		
		<u-navbar :placeholder="true" 
					bgColor="#000000"
		>
		    <view
		        class="u-nav-slot"
		        slot="left"
		    >
				<u-icon name="list" color="#ffffff" size="25" @click="clickMyindex"></u-icon>
		       <!-- <u-button color="#323232"  icon="man-add" iconColor="#ffd34d" shape="circle" text="上线中" size="mini"></u-button> -->
		        <u-button color="#323232" icon="order" @click="navigateTo(dispatch)" iconColor="#00ff00" shape="circle" :text="numbers" size="mini">
					派单<u-badge v-if="numbers!=0"  max="99" :value="numbers" ></u-badge>
					    <view v-else>(0)</view>
				</u-button> 
				
			</view>
		</u-navbar>
		<u-popup :show="show" @close="close" @open="open" mode="left" >
		    <view style="background-color: #f3f3f3;">
		        <myindex ref="myindex"></myindex>
		    </view>
		</u-popup>
	</view>
</template>

<script>
	import myindex from "../my/myindex.vue";

	
	
	import uRow from "@/pagesB/uview-ui/components/u-row/u-row";
	import uCol from "@/pagesB/uview-ui/components/u-col/u-col";
	import uDivider from "@/pagesB/uview-ui/components/u-steps/u-steps";
	import uSteps from "@/pagesB/uview-ui/components/u-steps/u-steps";
	import uStepsItem from "@/pagesB/uview-ui/components/u-steps-item/u-steps-item";
	import uButton from "@/pagesB/uview-ui/components/u-button/u-button";
	import uPopup from "@/pagesB/uview-ui/components/u-popup/u-popup";
	import uLoadmore from "@/pagesB/uview-ui/components/u-loadmore/u-loadmore";
	import uEmpty from "@/pagesB/uview-ui/components/u-empty/u-empty";
	import uTabs from "@/pagesB/uview-ui/components/u-tabs/u-tabs";
	import uTabbar from "@/pagesB/uview-ui/components/u-tabbar/u-tabbar";
	import uNavbar from "@/pagesB/uview-ui/components/u-navbar/u-navbar";
	import uIcon from "@/pagesB/uview-ui/components/u-icon/u-icon";
	import uBadge from "@/pagesB/uview-ui/components/u-badge/u-badge";
	import uCellGroup from "@/pagesB/uview-ui/components/u-cell-group/u-cell-group";
	import uCell from "@/pagesB/uview-ui/components/u-cell/u-cell";
	import {
		mapState
	} from 'vuex';  
	export default {
		components:{
			myindex,uRow,uCol,uDivider,uSteps,uStepsItem,uButton,uLoadmore,uPopup,uEmpty,uTabs,uTabbar,uNavbar,uIcon,uBadge,uCellGroup,uCell,
		}, 
		name: "navbar",
		data() {
			return {
				show:false,
				dispatch :'/pagesB/index/dispatch',//派单
				text:'/pages/text',//测试
				numbers:"0",
				pageVO:{
					pageNo: 1,
					pageSize: 4,
					technicianId:"", 
					receiveStatus:1,//技师接单状态（1未接单，2已接单，3服务中，4已完成，5拒绝接单，6取消）
					sort:"desc",//排序
				},
			};
		},
		mounted() {
			//获取当前位置 需用户授权
			this.pageVO.technicianId=this.userInfo.id
			this.showPage(false)
		},
		computed:{
			//获取是否登录
			...mapState(['hasLogin','userInfo']) 
		},
		methods:{
			//查询派单数量
			showPage(type){
				console.log("刷新刷新！！！")
				this.pageVO.technicianId=this.userInfo.id
				this.request.getRequest(this.http.httpsLian.orderDispatchRecord,this.pageVO, type)
				.then(res => {
					//console.log("sss："+JSON.stringify(res))
					if(res.code!=0 )return 
					this.numbers=res.data.total
				}).catch(res => {
					uni.$u.toast("网络异常3")
				})
			},
			clickMyindex(){
				this.show=true
				this.$refs.myindex.showPage();
				this.$refs.myindex.showNotice();
			},
			open() {
			  // console.log('open');
			},
			close() {
			  this.show = false
			  // console.log('close');
			},
			bobao(){
				this.request.getRequest(this.http.httpsLian.WebSocketGet,{id:2})
				.then(res => {
					console.log("sss："+JSON.stringify(res))
					
				}).catch(res => {
					uni.$u.toast("网络异常3")
				})
			},
			//页面跳转方法
			navigateTo(urls) {
				/* if(!this.userInfo.id){
					this.utils.notLogin()
					return
				} */
				uni.navigateTo({
				   url: urls
				});
			},
		}
	}
</script>

<style lang="scss">
/* #ifndef APP-NVUE */
	page {
		background-color: $u-bg-color;
	}
	/* #endif */
	
	.u-page {
		padding: 0;
		flex: 1;
		background-color: $u-bg-color;

		&__item {

			&__title {
				color: $u-tips-color;
				background-color: $u-bg-color;
				padding: 15px;
				font-size: 15px;

				&__slot-title {
					color: $u-primary;
					font-size: 14px;
				}
			}
		}
	}
	.u-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: $u-border-color;
		padding: 3px 0px;
		
		opacity: 0.8;
		.u-button{
			margin-left: 10px;
		}
		span{
			color: white;
			font-size: 14px;
		}
	}
	
</style>
